//模拟数据2
var data2 = [{
    title: '<i class="layui-icon" style="margin-right: 5px;"> &#xe656;</i>第九师流域水资源管理基础要素图层',
    id: 99,
    spread: true,
    children: [{
        title: '<img src="img/new_water_resource_lable/qhdm.png" class="tree-img">区划与地名'
        ,id: 0
    },{
        title: '<img src="img/new_water_resource_lable/tdtzj.png" class="tree-img">天地图影像注记'
        ,id: 1
    },{
        title: '<img src="img/new_water_resource_lable/hhsx.png" class="tree-img">河湖水系'
        ,id: 2
    },{
        title: '<img src="img/new_water_resource_lable/ggqd.png" class="tree-img">骨干渠道'
        ,id: 3
    },{
        title: '<img src="img/new_water_resource_lable/dq.png" class="tree-img">斗渠'
        ,id: 4
    },{
        title: '<img src="img/new_water_resource_lable/sb.png" class="tree-img">首部'
        ,id: 5
    },{
        title: '<img src="img/new_water_resource_lable/jdj.png" class="tree-img">机电井'
        ,id: 6
    },{
        title: '<img src="img/new_water_resource_lable/rygc.png" class="tree-img">人饮工程'
        ,id: 7
    },{
        title: '<img src="img/new_water_resource_lable/sk.png" class="tree-img">水库'
        ,id: 8
    },{
        title: '<img src="img/new_water_resource_lable/sdz.png" class="tree-img">水电站'
        ,id: 9
    },{
        title: '<img src="img/new_water_resource_lable/sz.png" class="tree-img">水闸'
        ,id: 10
    },{
        title: '<img src="img/new_water_resource_lable/bz.png" class="tree-img">泵站'
        ,id:11
    },{
        title: '<img src="img/new_water_resource_lable/df.png" class="tree-img">堤防'
        ,id: 12
    },{
        title: '<img src="img/new_water_resource_lable/xhtd.png" class="tree-img">泄洪通道'
        ,id: 13
    },{
        title: '<img src="img/new_water_resource_lable/cz.png" class="tree-img">水文测站'
        ,id: 14
    },{
        title: '<img src="img/new_water_resource_lable/fsjld.png" class="tree-img">灌区测水点'
        ,id: 15
    },{
        title: '<img src="img/new_water_resource_lable/qsk.png" class="tree-img">取水口'
        ,id: 16
    },{
        title: '<img src="img/new_water_resource_lable/gq.png" class="tree-img">灌区'
        ,id: 17
    }]
}];

//layui设置
layui.use(['jquery', 'form', 'table', 'layer', 'laydate',  'element', 'tree', 'util'], function(){
    $ = layui.$;
    form = layui.form;
    table = layui.table;
    layer = layui.layer;
    laydate = layui.laydate;
    element = layui.element;
    tree = layui.tree;
    util = layui.util;

    //开启复选框
    tree.render({
        elem: '#layer_list',
        id:'layer_list',
        data: data2,
        showCheckbox: true,
        showLine: false,
        oncheck: function(obj){
            var checkData = tree.getChecked('layer_list');
            if (checkData.length!=0){
                localStorage.setItem('checkData',JSON.stringify(checkData[0].children));
            }else{
                localStorage.setItem('checkData',JSON.stringify([]));
            }

        }
    });

    setTimeout(function(){
        var layer_selected = JSON.parse(localStorage.getItem('layer_selected'));
        tree.setChecked('layer_list', layer_selected);
    },100);


});

